package pl.koziolekweb.musicarchchecker;

import java.io.File;

public class LibraryValidator {

	private String defaultPath = "f:/";
	
	private String validateInput(String[] args) {
		if (args.length <= 0){
			System.out
					.println("Nie podano ściezki do biblioteki! Użyto domyślnej.");
			return defaultPath;
		}
		else{
			return args[0];
		}
	}

	private void isLibraryDir(File library) {
		if (!library.isDirectory())
			throw new IllegalArgumentException("Bilioteka nie jest katalogiem!");
	}

	public File validateAndCreate(String[] args) {
		File library = new File(validateInput(args));
		isLibraryDir(library);
		return library;
	}

}
